<template>
  <view class="work-container">
    <!-- 轮播图 -->
    <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
      <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
        <swiper-item v-for="(item, index) in data" :key="index">
          <view class="swiper-item" @click="clickBannerItem(item)">
            <image :src="item.image" mode="aspectFill" :draggable="false" />
          </view>
        </swiper-item>
      </swiper>
    </uni-swiper-dot>

    <!-- 宫格组件 -->
    <uni-section title="面料管理" type="line"></uni-section>
    <view class="grid-body">
      <uni-grid :column="4" :showBorder="false" @change="changeGrid" highlight>
        <uni-grid-item v-for="(item, index) in fabricMenuList" :key="index" :index="item.id">
          <view class="grid-item-box">
            <!-- <uni-icons :type="item.icon" size="30"></uni-icons> -->
			<u--image :src="item.src" alt="" width="30px" height="30px"/>
            <text class="text">{{item.text}}</text>
          </view>
        </uni-grid-item>
      </uni-grid>
    </view>
	<uni-section title="成品帘管理" type="line"></uni-section>
	<view class="grid-body">
	  <uni-grid :column="4" :showBorder="false" @change="changeGrid" highlight>
	    <uni-grid-item v-for="(item, index) in finishedMenuList" :key="index" :index="item.id">
	      <view class="grid-item-box">
	        <!-- <uni-icons :type="item.icon" size="30"></uni-icons> -->
			<u--image :src="item.src" alt="" width="30px" height="30px"/>
	        <text class="text">{{item.text}}</text>
	      </view>
	    </uni-grid-item>
	  </uni-grid>
	</view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        current: 0,
        swiperDotIndex: 0,
        data: [
		  {
            image: '/static/images/banner/banner01.jpg'
          },
          {
            image: '/static/images/banner/banner02.jpg'
          },
          {
            image: '/static/images/banner/banner03.jpg'
          }
        ],
		fabricMenuList:[
			{icon: 'search', text: '面料查询', id: 1, src: '/static/images/menu/01.png'},
			{icon: 'home-filled', text: '面料入库', id: 2, src: '/static/images/menu/02.png'},
			{icon: 'chat-filled', text: '库位调整', id: 3, src: '/static/images/menu/03.png'},
			{icon: 'circle', text: '面料订单', id: 4, src: '/static/images/menu/04.png'},
			{icon: 'flag-filled', text: '库存盘点', id: 5, src: '/static/images/menu/05.png'},
		],
		finishedMenuList: [
			{icon: 'map-filled', text: '成品订单查询', id: 6, src: '/static/images/menu/06.png'},
			{icon: 'more-filled', text: '成品帘任务', id: 7, src: '/static/images/menu/07.png'},
			{icon: 'plus-filled', text: '成品帘下料', id: 8, src: '/static/images/menu/08.png'},
			{icon: 'compose', text: '生产进度', id: 9, src: '/static/images/menu/09.png'},
		]
      }
    },
    methods: {
      clickBannerItem(item) {
        console.info(item)
      },
      changeSwiper(e) {
        this.current = e.detail.current
      },
      changeGrid(e) {
        console.log(e)
		const menuMap = {
			1: '/pages/fabricManagement/InventoryQuery/index',
			2: '/pages/fabricManagement/fabricStorage/index',
			3: '/pages/fabricManagement/warehouseAdjustment/index',
			4: '/pages/fabricManagement/fabricOrder/index',
			5: '/pages/fabricManagement/stocktaking/index',
			6: '/pages/finishedProductManagement/orderInquiry/index',
			7: '/pages/finishedProductManagement/finishedTask/index',
			8: '/pages/finishedProductManagement/finishedOrder/index',
			9: '/pages/finishedProductManagement/productionProgress/index',
		}
		this.$tab.navigateTo(menuMap[e.detail.index])
		// if(e.detail.index== 0) {
		// 	this.$tab.navigateTo('/pages/stocktaking/index')
		// }else {
		// 	this.$modal.showToast('模块建设中~')
		// }
      },
    }
  }
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #fff;
    min-height: 100%;
    height: auto;
  }

  view {
    font-size: 14px;
    line-height: inherit;
  }

  /* #endif */

  .text {
    text-align: center;
    font-size: 26rpx;
    margin-top: 10rpx;
  }

  .grid-item-box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
  }

  .uni-margin-wrap {
    width: 690rpx;
    width: 100%;
    ;
  }

  .swiper {
    height: 300rpx;
  }

  .swiper-box {
    height: 150px;
  }

  .swiper-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    height: 300rpx;
    line-height: 300rpx;
  }

  @media screen and (min-width: 500px) {
    .uni-swiper-dot-box {
      width: 400px;
      /* #ifndef APP-NVUE */
      margin: 0 auto;
      /* #endif */
      margin-top: 8px;
    }

    // .image {
    //   width: 20px;
    // }
	.menuImg {
		width: 20px;
		height: 20px;
	}
  }
</style>
